var common = require('../../../../utils/common.js');
var app = getApp();


Page({
    data: {
        __PUBLIC__:app.__PUBLIC__ ,
        displayFile:false,
        typeIndex:0,  
        type:['1.1.1','1.1.2','1.1.3','1.1.4','1.1.5'],
    },
    onLoad: function (options) {
        common.bestCurl('GET','/rent/detail',res=>{
            if(res.statusCode == 200){
                if(res.data.code==2){
                    console.log(res.data)
                }else{
                    if(res.data.rent_file.length!=0){
                        for (var index in res.data.rent_file) {
                            let url = res.data.rent_file[index].file_url;
                            let extStart = url.lastIndexOf(".");
                            let ext = url.substring(extStart, url.length).toUpperCase();
                            let pic = [
                                    '.JPG',
                                    '.PNG',
                                    '.JPEG',
                                    '.BMP',
                                    '.GIF',
                                    '.WEBP'
                                ];
                            if(pic.indexOf(ext)!=-1){
                                res.data.rent_file[index].ext = 'pic';
                            }else if(ext=='.DOC'||ext=='.DOCX'){
                                res.data.rent_file[index].ext = 'doc';

                            }else if(ext=='.PDF'){
                                res.data.rent_file[index].ext = 'pdf';
                            }else{
                                console.log('非法文件')
                            }   
                        }
                        this.setData({details:res.data,displayFile:true})
                    }else{
                        this.setData({details:res.data,displayFile:false})
                    }
                }
            }
        },{'id':options.id})
    },
    bindTypeChange:function(e){
        this.setData({
            typeIndex: e.detail.value
        })
    }
    
})